<template>
  <transition name="fade">
    <div class="l_message" v-if="isShow">
      {{message}}
    </div>
  </transition>
</template>

<script type="text/javascript">
  export default {
    name: 'l_message',
    data () {
      return {
        message: '',
        time: 3000,
        isShow: true
      }
    },
    mounted () {
      this.autoClose()
    },
    methods: {
      autoClose () {
        var _this = this
        window.setTimeout(function () {
          _this.isShow = false
        }, this.time)
      }
    }
  }
</script>

<style type="text/css">
  .l_message {
    font-size: 0.6rem;
    position: fixed;
    padding: 10px;
    color: #fff;
    background-color: rgba(0,0,0,0.6);
    border-radius: 5px;
    top: 30%;
    left: 50%;
    transform: translate(-50%);
    z-index: 99999;
  }
  .fade-enter-active, .fade-leave-active {
    transition: opacity .5s
  }
  .fade-enter, .fade-leave-to {
    opacity: 0
  }
</style>